package pro.shushi.pamirs.hr.core.init;

import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import pro.shushi.pamirs.boot.common.api.command.AppLifecycleCommand;
import pro.shushi.pamirs.boot.common.api.init.InstallDataInit;
import pro.shushi.pamirs.boot.common.api.init.ReloadDataInit;
import pro.shushi.pamirs.boot.common.api.init.UpgradeDataInit;
import pro.shushi.pamirs.hr.api.HrSimpleModule;
import pro.shushi.pamirs.hr.core.task.DepartmentStaffStatTask;
import pro.shushi.pamirs.meta.annotation.fun.extern.Slf4j;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * HR示例标准版的数据初始化
 *
 * @author shushi
 */
@Slf4j
@Component
@Order(0)
public class HrSimpleAppDataInit implements InstallDataInit, UpgradeDataInit, ReloadDataInit {

    @Resource
    private DepartmentStaffStatTask departmentStaffStatTask;

    @Override
    public boolean init(AppLifecycleCommand command, String version) {
        departmentStaffStatTask.initTask();
        return true;
    }

    @Override
    public boolean upgrade(AppLifecycleCommand command, String version, String existVersion) {
        departmentStaffStatTask.initTask();
        return true;
    }

    @Override
    public boolean reload(AppLifecycleCommand command, String version) {
        departmentStaffStatTask.initTask();
        return true;
    }

    @Override
    public List<String> modules() {
        return Collections.singletonList(HrSimpleModule.MODULE_MODULE);
    }

    @Override
    public int priority() {
        return 0;
    }
}
